package validator

import (
	"regexp"

	"github.com/asaskevich/govalidator"
)

func Validate(post interface{}) (valid bool, err error) {
	regx := regexp.MustCompile("^[1][3,4,5,7,8][0-9]{9}$")

	govalidator.TagMap["mobile"] = govalidator.Validator(func(str string) bool {
		return regx.MatchString(str)
	})

	result, err := govalidator.ValidateStruct(post)
	return result, err
}
